import type { RouteRecordRaw } from 'vue-router';

const StructureTree = () => import('./view/StructureTree.vue')
const ReportTree = () => import('./view/ReportTree.vue')

const CostView = () => import('./view/CostSetting.vue')
const ProjectView = () => import('./view/ProjectOverview.vue')
const ReportsView = () => import('./view/Reports.vue')
const SettingsView = () => import('./view/Settings.vue')

const PropertiesPanel = () => import('./view/PropertiesPanel.vue')
const ToolsPanel = () => import('./view/ToolsPanel.vue')

import { useEvents } from '../../platform/events/useEventBus'

export default {
  registerRoutes: (): RouteRecordRaw[] => [
    {
      path: 'file',
      children: [
        {
          path: 'project',
          name: 'Project',
          components: {
            default: ProjectView,
            sidebar: StructureTree,
          },
          meta: { title: '项目概览', sidebarVisible: true },
          children: [
            {
              path: 'properties',
              name: 'PropertiesPanel',
              component: PropertiesPanel,
            },
            {
              path: 'tools',
              name: 'ToolsPanel',
              component: ToolsPanel,
            }
          ]
        },
        {
          path: 'cost',
          name: 'Cost',
          components: {
            default: CostView,
            sidebar: StructureTree,
          },
          meta: { title: '成本设置' }
        },
        {
          path: 'reports',
          name: 'Reports',
          components: {
            default: ReportsView,
            sidebar: ReportTree,
          },
          meta: { title: '报表', sidebarVisible: true }
        },
        {
          path: 'settings',
          name: 'Settings',
          component: SettingsView,
          meta: { title: '系统设置', sidebarVisible: false }
        },
      ]
    }
  ],
  
  onMount: () => {
    console.log('[文件模块] 已挂载');
    useEvents().onGlobal('COPY', (data: any) => {
      console.log(data);
    })

  },
  
  onUnmount: () => {
    console.log('[文件模块] 已卸载');
  }
};